package main

import (
	"fmt"
	"gitee.com/xiang-changhua/struct2-json"
)

/**步骤
1，准备数据结构体
2，准备要序列化的结构体数据
3，调用序列化函数
 */

type Student struct {
	Name string
	Age int
}

type Teacher struct {
	Name string
	Age int
	Students []Student
}

func main() {

	teacher := Teacher{
		Name: "Teacher 1",
		Age: 25,
		Students: []Student{
			{Name:"Stu001",Age: 1},
			{Name:"Stu002",Age: 2},
			{Name:"Stu003",Age: 3},
		},
	}

	if result ,err := src.Struct2Json(teacher); err == nil {
		fmt.Println(result)
	}else {
		fmt.Println(err)
	}
}
